Write-Host -ForegroundColor Yellow "IIS: Installing IIS on $env:computername."

import-module servermanager

$installed = $true

$GetFeatures = Get-WindowsFeature web*,app*,smtp*,net*

foreach ($feature in $GetFeatures){
	if ($feature.Installed -eq $false) {
	$installed = $false
	break
	}
}


	if ($installed){
	Write-Host -ForegroundColor Gray "IIS has already been installed on $env:computername : Skipping."
	} 
	else 
	{
	Add-WindowsFeature web-server, Application-Server, SMTP-Server, NET-Framework, WAS -IncludeAllSubFeature | Tee-Object -variable FeatureAdd

	
		if ($FeatureAdd.RestartNeeded)
		{
			$env:restart = $true 
			Write-Host -ForegroundColor Red "Reboot is necesary on $env:computername before continuing installation."
		} else 
		{
			Write-Host -ForegroundColor Yellow "IIS: Installing IIS on $env:computername. COMPLETED"
		}
	}
		
